# Detect GDK2_PIXMAP
#
# NOTE: This is a modified version of FindLLVM


if (GTK2_GDKPIXBUF_INCLUDE_DIR)
  set(GTK2_GDKPIXBUF_FOUND TRUE)
else (GTK2_GDKPIXBUF_INCLUDE_DIR)

  find_program(GTK2_GDKPIXBUF_CONFIG_EXECUTABLE
      NAMES pkg-config
      PATHS /opt/local/bin /usr/bin /usr/local/bin
  )

  exec_program(${GTK2_GDKPIXBUF_CONFIG_EXECUTABLE} ARGS  gdk-pixbuf-2.0 --version OUTPUT_VARIABLE GTK2_GDKPIXBUF_STRING_VERSION )
  MESSAGE(STATUS "gdk-pixbuf-2.0 version: " ${GTK2_GDKPIXBUF_STRING_VERSION})
  transform_version(GTK2_GDKPIXBUF_VERSION ${GTK2_GDKPIXBUF_STRING_VERSION})
  
  exec_program(${GTK2_GDKPIXBUF_CONFIG_EXECUTABLE} ARGS gdk-pixbuf-2.0 --cflags OUTPUT_VARIABLE GTK2_GDKPIXBUF_INCLUDE_DIRS )

  MESSAGE(STATUS "gdk-pixbuf-2.0 flags: " ${GTK2_GDKPIXBUF_INCLUDE_DIRS})
  exec_program(${GTK2_GDKPIXBUF_CONFIG_EXECUTABLE} ARGS gdk-pixbuf-2.0 --libs   OUTPUT_VARIABLE GTK2_GDKPIXBUF_LDFLAGS )
  MESSAGE(STATUS "gdk-pixbuf-2.0 libs: " ${GTK2_GDKPIXBUF_LDFLAGS})

  if(GTK2_GDKPIXBUF_INCLUDE_DIR)
    set(GTK2_GDKPIXBUF_FOUND TRUE)
  endif(GTK2_GDKPIXBUF_INCLUDE_DIR)
  
  if(GTK2_GDKPIXBUF_FOUND)
    message(STATUS "Found gdk-pixbuf-2.0")
  else(GTK2_GDKPIXBUF_FOUND)
    if(GTK2_GDKPIXBUF_FIND_REQUIRED)
      message(FATAL_ERROR "Could NOT find gdk-pixbuf-2.0")
    endif(GTK2_GDKPIXBUF_FIND_REQUIRED)
  endif(GTK2_GDKPIXBUF_FOUND)

endif (GTK2_GDKPIXBUF_INCLUDE_DIR)
